package com.sugar.follow.up.module.business.controller.app.doctor;

import com.sugar.follow.up.framework.common.pojo.CommonResult;
import com.sugar.follow.up.framework.common.util.object.BeanUtils;
import com.sugar.follow.up.module.business.controller.admin.doctor.vo.DoctorRespVO;
import com.sugar.follow.up.module.business.service.doctor.DoctorService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import java.util.List;

import static com.sugar.follow.up.framework.common.pojo.CommonResult.successApp;

@Tag(name = "APP - 医生")
@RestController
@RequestMapping("/biz/doctor")
@Validated
public class AppDoctorController {

    @Resource
    private DoctorService doctorService;

    @GetMapping("/get")
    @Operation(summary = "获得医生详情")
    @PermitAll
    public CommonResult<DoctorRespVO> getDoctorDetail(@RequestParam("id") Long id) {
        return successApp(BeanUtils.toBean(doctorService.getDoctor(id), DoctorRespVO.class));
    }

    @GetMapping("/all")
    @Operation(summary = "获得所有医生")
    @PermitAll
    public CommonResult<List<DoctorRespVO>> getDoctorPage() {
        return successApp(doctorService.getDoctorAllList());
    }
}